/**
 * @param {number[][]} wall
 * @return {number}
 */
 var leastBricks = function(wall) {
    let width=wall[0].reduce((a,b) => a+b);
    let candidates=new Map();
    for(let w of wall){
        let temp=0;
        for(let e of w){
            temp+=e;
            if(candidates.has(temp)){
                candidates.set(temp,candidates.get(temp)+1);
            }
            else{
                candidates.set(temp,1)
            }
        }
    }
    candidates.delete(width);
    return candidates.size ? wall.length-Math.max(...candidates.values()):wall.length;
};

//  